package org.goyo.main.domain.dao.system.impl;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.apache.commons.lang.StringUtils;
import org.goyo.common.exception.DBException;
import org.goyo.common.utils.Pager;
import org.goyo.main.domain.dao.BaseDAO;
import org.goyo.main.domain.dao.system.ISysDepGroupDao;
import org.goyo.main.domain.entity.system.SysDepGroup;
import org.springframework.stereotype.Repository;

@Repository
public class SysDepGroupDaoImpl extends BaseDAO implements ISysDepGroupDao{

	@Override
	public List<SysDepGroup> findByCond(Map<String, Object> cond, Pager pager) {
		StringBuffer buf = new StringBuffer("from SysDepGroup where 1=1 order by number");
		List<Object> params = getCondition(buf, cond);
		return this.findObjects(buf.toString(), pager, params.toArray());
	}

	public List<Object> getCondition(StringBuffer buf,Map<String, Object> cond){
		List<Object> params = new ArrayList<Object>();
		return params;
	}

  @Override
  public Pager findByCondition(String cond, Pager pager) throws DBException {
    StringBuffer buf = new StringBuffer("from SysDepGroup where 1=1 ");
    if (StringUtils.isNotBlank(cond)) {
      buf.append(" and ");
      buf.append(cond);
    }
        String hql = this.addSort(buf, pager);
        String countHql = "select count(*) "+buf.toString();
     return this.findObjectsByPager(hql,countHql, pager);
}
}
